package file;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo3 {
    public static void main(String[] args) {
        File dir=new File(".");
        //如果是目录
        if (dir.isDirectory()){

        File[] subs=dir.listFiles(pathname-> pathname.getName().endsWith("txt"));
        for (File sub:subs){
            System.out.println(sub.getName());//输出名字
        }
            }
    }
}
